package com.itheima.reggie.config.common;

/**
 * 基于ThreadLocal封装的工具类，用于保存和获取当前登录用户id
 *
 * @Name BaseContext
 * @Author BaiXin
 * @Date 2022-10-31 09:46
 */
public class BaseContext {
    private  static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    /**
     * 设置值
     * @param id
     */
    public static void setThreadLocal(Long id){
        threadLocal.set(id);
    }

    /**
     * 获取值
     * @return
     */
    public static Long getThreadLocal(){
       return threadLocal.get();
    }

    /**
     * 移出值
     */
    public static void remove(){
        threadLocal.remove();
    }
}
